
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="xms">
    <meta name="author" content="xms">
    <link rel="icon" href="/content/favicon.ico">

    <title>自定义 - 实体 - 关系</title>

    <!-- Bootstrap core CSS -->
    <link href="/content/css/bootstrap3.3.5/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="/content/css/dashboard.css" rel="stylesheet">
    <link href="/content/css/font-awesome.min.css" rel="stylesheet">
    <link href="/content/customize/css/common.css" rel="stylesheet">
    <link href="/content/js/jquery-toast/jquery.toast.min.css" rel="stylesheet">
    <link id="themeLink" href="/content/css/theme/default.css" rel="stylesheet" />
    <!-- Bootstrap core JavaScript ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/content/js/jquery.min.js"></script>
    <script src="/content/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="/content/js/ie10-viewport-bug-workaround.js"></script>
    <script src="/content/js/jquery.bootstrap.min.js"></script>
    <script src="/content/js/json2.js"></script>
    <script src="/content/js/xms.utility.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.core.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.widget.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.mouse.js"></script>
    <script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.draggable.js"></script>
    <script src="/content/js/jquery-toast/jquery.toast.min.js"></script>
    <script src="/content/js/xms.jquery.js"></script>
    <script src="/content/js/xms.web.js"></script>
    <script src="/content/js/xms.metadata.js"></script>
    <script src="/content/js/md5.js" type="text/javascript"></script>
    <script src="/content/js/commonlabels.js"></script>
    <script src="/content/js/common/pagecontext.js"></script>
    <script src="/api/user/usercontext"></script>
    <script>
        jQuery(function () {
            Xms.Web.Loading();
            function aLinkClick(e) {

                if (currentKeycode != 17 && window.parent && window.parent.addToTab) {
                    e.preventDefault();
                    var tabNav = $('#customTabNav', parent.document).children('.iframe-link-linkitem.active');
                    var textEl = tabNav.clone();
                    $(".glyphicon-remove", textEl).remove();
                    var label = textEl.text();
                    textEl = $(this).clone();
                    $("span", textEl).remove();
                    label = label + '-' + textEl.text();
                    var link = $(this).attr("href");
                    var id = $.md5(link);
                    Xms.Web.callParentMethod('addToTab', { id: id, label: label, link: link });
                    return false;
                } else {
                    //  currentKeycode = -99999;
                    //  var link = $(this).attr("href");
                    //  Xms.Web.OpenWindow(link);
                }

            }
            var currentKeycode = -99999;
            $("body").on("click.customizeLinkclick", 'a[href]a:not([href^="javascript:"])a:not([href^="#"])', function (e) {
                aLinkClick.call(this, e);
            });
        });
    </script>
    <link href="/content/customize/css/common.css" rel="stylesheet">
    <link href="/content/js/jquery-ui-1.10.3/themes/base/jquery.ui.all.css" rel="stylesheet">
    <link href="/content/js/grid/pqgrid.dev.css" rel="stylesheet">
    <style>
        body {
            padding: 0;
            margin: 0;
        }

        .table-responsive {
            max-height: 400px;
            overflow-y: auto;
        }

        .panel-default .panel-heading {
            background-color: white;
        }
    </style>
</head>
<body>
<div class="" id="body">
    <div class="clearfix">
        <div class="col-md-12" id="main">
            <div class="" style="padding:5px;" id="renderBody">
                <!--main-->
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">
                            <a data-toggle="collapse"
                               href="#collapseTwo">
                                <strong>关系</strong>
                            </a>
                        </h3>
                    </div>
                    <div id="collapseTwo" class="panel-collapse collapse in">
                        <div class="panel-body">
                            <div class="" id="gridview">
                                <div class="datagrid-view"></div>
                                <div class="table-datagrid-view">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <nav class="navbar navbar-default navbar-fixed-bottom hide" role="navigation" id="body-footer">
                <div class="container">
                    <div class="navbar-form navbar-right" id="body-footer-content">
                    </div>
                </div>
            </nav>
        </div>
    </div>
</div>

<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.button.js"></script>
<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.mouse.js"></script>
<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.autocomplete.js"></script>
<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.draggable.js"></script>
<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.resizable.js"></script>
<script src="/content/js/jquery-ui-1.10.3/ui/jquery.ui.tooltip.js"></script>
<script src="/content/js/fetch.js"></script>
<script src="/content/js/common/filters.js"></script>
<script src="/content/js/grid/pqgrid.dev.js"></script>
<script src="/content/js/grid/localize/pq-localize-zh.js"></script>
<script src="/content/js/cdatagrid.js"></script>
<script src="/content/js/jquery.bootpag.min.js"></script>
<script src="/content/js/jquery.form.js"></script>
<script src="/content/js/jquery-validate/jquery.validate.min.js"></script>
<script>
    var pageUrl = '';
    var solutionid = '';
    var enityid = ''
    var type = '';
    $(function () {
        var model = $.urlParamObj(location.href);
        enityid = model.entityid;
        type = model.type;
        var theaders = {
            'relationship_name': '名称',
            'relationship_referencedentitylocalizedname': '主要实体',
            'relationship_referencingentitylocalizedname': '关联实体',
            'relationship_referencingattributelocalizedname': ' 字段名称',
            'operation':'操作'
        }
        //列数据配置数据
        var columnConfigs = [
            //从新配置复选框列的渲染方式，
            {
                title: "", dataIndx: "recordid", maxWidth: 48, minWidth: 48, align: "center", resizable: false,
                type: 'checkBoxSelection', cls: 'ui-state-default', sortable: false, editable: false,
                render: function (ui) {
                    //  console.log(ui)
                    return '<input type="checkbox" value="' + ui.rowData.relationshipid + '" name="recordid" class="">'
                },
                cb: { all: true, header: true }
            },
            {
                title: "", dataIndx: "hidden", maxWidth: 30, minWidth: 30, align: "center", resizable: false,
                cls: 'ui-state-default', sortable: false, editable: false,
                hidden:true,
                render: function (ui) {
                    //  console.log(ui)
                    return '<input type="hidden" value="' + ui.rowData.relationshipid + '" name="componenttypename" class="">'
                },
                cb: { all: true, header: true }
            },
            { "dataIndx": "name", "title": theaders.relationship_name, editable: false, "dataType": "string", "width": 150, "isprimaryfield": false, "attributetypename": "string" },
            { "dataIndx": "referencedentitylocalizedname", "title": theaders.relationship_referencedentitylocalizedname, "dataType": "string", editable: false, "width": 150, "isprimaryfield": false, "attributetypename": "string" },

            { "dataIndx": "referencingentitylocalizedname", "title": theaders.relationship_referencingentitylocalizedname, editable: false, "dataType": "string", "width": 100, "isprimaryfield": false, "attributetypename": "string" },
            { "dataIndx": "referencingattributelocalizedname", "title": theaders.relationship_referencingattributelocalizedname, editable: false, "dataType": "string", "width": 150, "isprimaryfield": false, "attributetypename": "string" },
            {
                title: "操作", editable: false, minWidth: 120,width:120, notHeaderFilter: true, editable: false, sortable: false, render: function (ui) {
                    var datas = ui.rowData;
                    var dataIndx = ui.dataIndx;
                    var column = ui.column;
                    var recordid = datas[dataIndx];
                    var html = ''
                    html =' <a class="btn btn-default btn-xs" href="/xms/customize/relationship/edit?id=' + datas.relationshipid + '"><span class="glyphicon glyphicon-edit"></span> 配置</a>';
                    return html
                }
            }
        ];
        var url = ORG_SERVERURL + '/api/schema/relationship/list?LoadData=true&type='+type+'&entityid='+enityid;
        var $form = $('#searchForm');
        var roles_filters = new XmsFilter();
        var datagridconfig = {
            scrollModel: { autoFit: true },
            baseUrl: url,
            columnConfigs: columnConfigs,//字段配置信息
            context: $('#gridview'),//底部操作按钮方法触发
            filters: roles_filters,//post提交时过滤条件
            searchForm: $form//GET提交时查询的数据
        };
        $('.datagrid-view').xmsDataTable(datagridconfig);
        Xms.Web.Event.localStorageEvent.on('list_relationship_rebind', function () {
            setTimeout(function () {
                location.reload();
            },100)
        });

    });

    function rebind() {
        //$('#searchForm').submit();
        $('.datagrid-view').cDatagrid('refreshDataAndView')
    }
</script>

</body>
</html>